package com.acme.bankapp.domain.bank;

public class Client {

	private Account account;
	private String name;
	private Gender gender;

	public Client(String name, Gender gender, Account account) {
		this.account = account;
		this.name = name;
		this.gender = gender;
	}
	
	public String getClientSalutation() {
		return String.format("%s %s", gender.getHonorific(), name);
	}
	
	public Account getAccount() {
		return account;
	}
	
	public String toString() {
		return String.format("Name: %s.%nAccount: %s.%n",
					this.getClientSalutation(),
					this.getAccount());
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((gender == null) ? 0 : gender.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Client other = (Client) obj;
		if (gender != other.gender)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
	

}
